<template>
  <div class="mine-system-message">
    <div class="system-messages-box" v-for="message of systemMessages" :key="message.id">
      <div class="message-headline">{{message.headline}}</div>
      <div class="message-content">{{message.content}}</div>
      <div class="message-time">{{ message.create_time | timeStrToDate | dateTotoLocaleDateStr }}</div>
    </div>
  </div>
</template>

<script>
import { getSystemMessage } from '__SERVICE__/user.js'
export default {
  name: 'MineSystemMessage',
  data: ()=>({
    systemMessages: []
  }),
  computed: {
    deadUserInfo() {
      return this.$store.state.user.deadUserInfo
    }
  },
  methods: {
    async getSystemMessage() {
      const result = await getSystemMessage(this.deadUserInfo.user_id)
      const {data: {system_messages}} = result
      this.systemMessages = Object.freeze(system_messages)
    }
  },
  mounted() {
    this.getSystemMessage()
  }
}
</script>

<style lang="less">
  .mine-system-message {
    margin-top: 1rem;
    .system-messages-box {
      width: 95%;
      margin: 0 auto;
      box-sizing: border-box;
      padding: 0.75rem 1rem;
      margin-bottom: 1rem;
      box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.15);
      .message-headline, .message-time  {
        font-size: 0.8rem;
        font-weight: lighter;
        
        color: rgb(56, 56, 56);
      }
      .message-content {
        font-size: 0.9rem;
        margin: 0.25rem 0;
        text-indent: 0.25rem;
      }
    }
  }
</style>